<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .mybutton{
            background-color: green;
            color: red;
        }
    </style>
</head>
<body>
    <a href="http://www.baidu.com">百度</a>
    <hr>
    <button>百度</button>
    <script>
        // 禁止a标签跳转
        document.querySelector('a').onclick = function(){
            return false;
        }

        // 给button添加点击事件  进行跳转
        document.querySelector('button').onclick = function(){
            // console.log(this)
            this.className = 'mybutton'
            document.querySelector('title').innerHTML = '事件操作'
            // 跳转页面  BOM对象
            // location.href = 'http://www.baidu.com'
        }
    </script>
</body>
</html>